package x.trident.core.sequence.starter.autoconfiguration;

import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.core.script.RedisScript;

/**
 * reids lua脚本加载器
 *
 * @author 林选伟
 * @date 2023-06-01
 */
public final class AutoConfigurationUtils {
    private AutoConfigurationUtils() {
    }

    public static RedisScript<Long> loadSeqenceLuaScript() throws Exception {
        DefaultRedisScript<Long> result = new DefaultRedisScript<>();
        result.setLocation(new ClassPathResource("generateSeqence.lua"));
        result.setResultType(Long.class);
        result.afterPropertiesSet();
        return result;
    }
}
